package com.kancy.swing.tip;


import com.kancy.swing.log.Log;

import javax.swing.*;
import java.awt.*;
import java.util.Objects;

/**
 * Alert
 *
 * @author kancy
 * @date 2020/2/16 2:58
 */
public class Alert {

    /**
     * 提示信息
     * @param msgFormat
     * @param args
     */
    public static void msg(String msgFormat, Object ... args){
        msg(JOptionPane.getRootFrame(), msgFormat, args);
    }

    /**
     * 提示信息
     * @param component
     * @param msgFormat
     * @param args
     */
    public static void msg(Component component, String msgFormat, Object ... args){
        if (Objects.nonNull(msgFormat)){
            msgFormat = msgFormat.replace("{}", "%s");
            Log.warn(msgFormat, args);
            MessageDialog messageDialog = new MessageDialog(component, String.format(msgFormat, args));
            messageDialog.show();
        }
    }

}
